//
//  MoreTableViewController.m
//  Kjs-iOS
//
//  Created by Pat on 16/8/5.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "MoreTableViewController.h"
#import "MapTool.h"
#import "BriefIntroViewController.h"
#import "KJSRequest.h"
#import "ContactUsTableViewController.h"
#import "AnnouncementViewController.h"
#import "MessagePushTableViewController.h"
#import "FeedbackViewController.h"
#import "AppDelegate.h"
#import "HelpCenterViewController.h"
@interface MoreTableViewController ()

@end

@implementation MoreTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"更多";
    self.tableView.allowsSelection = YES;
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 6;
    } else if (section == 1) {
        return 3;
    }
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (section == 0) {
        return 15.f;
    } else {
        return 0.00001;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        switch (indexPath.row) {
            case 0: //系统消息
            case 1: //平台动态
            case 2: //业内新闻
            {
                AnnouncementViewController * announcementVC = [[AnnouncementViewController alloc] initWithViewControllerIdentifier:@"AnnouncementViewController"];
                announcementVC.announcementType = indexPath.row;
                if (indexPath.row == 0) {
                    [CurentDelegate getAccountMessageAt:self ret:^(UserInfo *account) {
                        //系统消息界面要求登录
                        [self displayViewController:announcementVC];
                    }];
                } else {
                    [self displayViewController:announcementVC];
                }
                break;
            }
            case 3: {
                //帮助中心
                HelpCenterViewController * helpCenterVC = [[HelpCenterViewController alloc] initWithViewControllerIdentifier:@"HelpCenterViewController"];
                [KJSRequest getPlatformInfoForAppWithSign:@"0"
                                                      ret:^(BriefIntroModel *model) {
                                                          helpCenterVC.briefIntro = model.result;
                                                          [self displayViewController:helpCenterVC];
                                                      }];
                break;
            }
            case 4: {
                //平台简介
                BriefIntroViewController * briefVC = [[BriefIntroViewController alloc] initWithViewControllerIdentifier:@"BriefIntroViewController"];
                [KJSRequest getPlatformInfoForAppWithSign:@"1"
                                                      ret:^(BriefIntroModel *model) {
                                                          briefVC.briefIntro = model.result;
                                                          [self displayViewController:briefVC];
                                                      }];
                break;
            }
            case 5: {
                //联系我们
                ContactUsTableViewController * contactUsVC = [[ContactUsTableViewController alloc] initWithViewControllerIdentifier:@"ContactUsTableViewController"];
                [KJSRequest getPlatformInfoForAppWithSign:@"2"
                                                      ret:^(BriefIntroModel *model) {
                                                          contactUsVC.briefIntro = model.result;
                                                          [self displayViewController:contactUsVC];
                                                      }];
                break;
            }
            default:
                break;
        }
    } else {
        switch (indexPath.row) {
            case 0: {
                //消息推送
                MessagePushTableViewController * messagePushVC = [[MessagePushTableViewController alloc] initWithViewControllerIdentifier:@"MessagePushTableViewController"];
                [self displayViewController:messagePushVC];
                break;
            }
            case 1: {
                //意见反馈
                FeedbackViewController * feedbackVC = [[FeedbackViewController alloc] initWithViewControllerIdentifier:@"FeedbackViewController"];
                [self displayViewController:feedbackVC];
                break;
            }
            case 2: {
                [self.tableView cellForRowAtIndexPath:indexPath].selected = NO;
                break;
            }
            default:
                break;
        }
    }
}
@end
